//
//  MMSecurityView.m
//  ZZLC
//
//  Created by 杨春至 on 2017/12/14.
//  Copyright © 2017年 ZhongZeng. All rights reserved.
//

#import "MMSecurityView.h"

@interface MMSecurityView ()

@property (nonatomic,strong) UILabel *titleLb;

@property (nonatomic,strong) UIView *lineView;

@property QMUIButton *btn1;

@property QMUIButton *btn2;

@property QMUIButton *btn3;

@end

@implementation MMSecurityView
- (instancetype)init{
    if ([super init]) {
        [self configUI];
    }
    return self;
}
- (void)configUI{
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.titleLb];
    [self addSubview:self.lineView];
    self.btn1 = [self creatBtnByImageName:@"secureicon" andTitleStr:@"三方机构\n资金托管"];
    self.btn2 = [self creatBtnByImageName:@"icpicon" andTitleStr:@"ICP认证\n安全可靠"];
    self.btn3 = [self creatBtnByImageName:@"multipleicon" andTitleStr:@"风险保障\n多重管控"];
    [self addSubview:self.btn1];
    [self addSubview:self.btn2];
    [self addSubview:self.btn3];
}
- (void)layoutSubviews{
    CGFloat gap = 15;
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(gap));
        make.top.equalTo(@0);
        make.height.equalTo(@45);
        make.width.equalTo(self);
    }];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self);
        make.top.equalTo(_titleLb.mas_bottom);
        make.height.equalTo(@(0.4));
        make.width.equalTo(self);
    }];
    [_btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX).multipliedBy(0.4);
        make.top.equalTo(_lineView.mas_bottom).offset(gap);
        make.bottom.equalTo(self.mas_bottom).offset(-gap);
        make.width.equalTo(self).multipliedBy(0.3);
    }];
    [_btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(_lineView.mas_bottom).offset(gap);
        make.bottom.equalTo(self.mas_bottom).offset(-gap);
        make.width.equalTo(self).multipliedBy(0.3);
    }];
    [_btn3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX).multipliedBy(1.6);
        make.top.equalTo(_lineView.mas_bottom).offset(gap);
        make.bottom.equalTo(self.mas_bottom).offset(-gap);
        make.width.equalTo(self).multipliedBy(0.3);
    }];
}
- (QMUIButton *)creatBtnByImageName:(NSString*)nameStr andTitleStr:(NSString *)titleStr{
    QMUIButton *btn = [[QMUIButton alloc]init];
    [btn setTitle:titleStr forState:UIControlStateNormal];
    [btn setImage:UIImageMake(nameStr) forState:UIControlStateNormal];
    btn.imagePosition = QMUIButtonImagePositionTop;
    btn.backgroundColor = [UIColor clearColor];
    btn.titleLabel.numberOfLines = 0;
    btn.titleLabel.font = [UIFont systemFontOfSize:12];
    btn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0.0, 0);
    btn.titleEdgeInsets = UIEdgeInsetsMake(6, 0, 0.0, 0);
    [btn setTitleColor:RGBCOLOR(214, 214, 214) forState:UIControlStateNormal];
    btn.userInteractionEnabled = NO;
    return btn;
}
- (UILabel *)titleLb{
    if (!_titleLb) {
        _titleLb = [[UILabel alloc]init];
        _titleLb.text = @"安全保障";
        _titleLb.font = [UIFont systemFontOfSize:15];
    }
    return _titleLb;
}
- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = [UIColor grayColor];
    }
    return _lineView;
}

@end
